//
//  StatusRetweetedCell.swift
//  weibo
//
//  Created by 陈伟 on 15/10/22.
//  Copyright © 2015年 陈伟. All rights reserved.
//

import UIKit

class StatusRetweetedCell: StatusCell {

    private lazy var backButton: UIButton = {
        let button = UIButton()
        button.backgroundColor = UIColor(white: 0.9, alpha: 1)
        return button
    }()
    
    private lazy var retweetedLabel: UILabel = UILabel(title: "转发转发转发转发转发转发转发转发转发转发转发转发转发转发转发转发转发转发转发", fontsize: 14, color: UIColor.darkGrayColor(), screenInset: statusCellMargin)
    
//    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
//        super.init(style: style, reuseIdentifier: reuseIdentifier)
//        
//        setupUI()
//    }
//
//    required init?(coder aDecoder: NSCoder) {
//        fatalError("init(coder:) has not been implemented")
//    }
//    override var viewModel: StatusViewModel? {
//        didSet {
//            
//        }
//    }
    override var statusModel: StatusViewModel? {
        didSet {
            retweetedLabel.text = statusModel?.retweetedText
            
            pictureView.snp_updateConstraints { (make) -> Void in
            let offset = statusModel?.thumbnailUrls?.count > 0 ? statusCellMargin : 0
            make.top.equalTo(retweetedLabel.snp_bottom).offset(offset)
            }
        }
    }
    override func setupUI() {
        super.setupUI()
//        contentView.addSubview(backButton)
//        contentView.addSubview(retweetedLabel)
        contentView.insertSubview(backButton, belowSubview: pictureView)
        contentView.insertSubview(retweetedLabel, aboveSubview: backButton)
        
        backButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(statusTextLabel.snp_bottom).offset(statusCellMargin)
            make.left.equalTo(contentView.snp_left)
            make.right.equalTo(contentView.snp_right)
            make.bottom.equalTo(bottomView.snp_top)
        }
        
        retweetedLabel.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(backButton.snp_top).offset(statusCellMargin)
            make.left.equalTo(backButton.snp_left).offset(statusCellMargin)
        }
        
        pictureView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetedLabel.snp_bottom).offset(statusCellMargin)
            make.left.equalTo(retweetedLabel.snp_left)
            make.width.equalTo(300)
            make.height.equalTo(90)
        }
    }
    
}
